/**
 * @file WordSegmentation.hpp
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2022-04-05
 *
 * @copyright Copyright (c) 2022
 *
 */

#pragma once

#include "cppjieba/Jieba.hpp"

#include <iostream>
#include <string>
#include <vector>

using std::cout;
using std::endl;
using std::string;
using std::vector;

namespace wd
{

// jieba dict
const char *const DICT_PATH = "/home/snow/gitee/cppjieba/dict/jieba.dict.utf8";
const char *const HMM_PATH = "/home/snow/gitee/cppjieba/dict/hmm_model.utf8";
const char *const USER_DICT_PATH = "/home/snow/gitee/cppjieba/dict/user.dict.utf8";

class WordSegmentation
{
  public:
    WordSegmentation()
        : _jieba(DICT_PATH, HMM_PATH, USER_DICT_PATH)
    {
        cout << "cppjieba init!" << endl;
    }

    vector<string> operator()(const char *src)
    {
        vector<string> words;
        _jieba.CutAll(src, words); // cut with hmm
        return words;
    }

  private:
    cppjieba::Jieba _jieba;
};

} // end of namespace wd
